import { db } from './connect'
import { Random } from 'mockjs'
import { findAll } from './query'

db.exec(`
    create table if not exists logs(
        id integer primary key autoincrement not null,
        date text not null,
        content text not null,
        created_at text not null
    );
    `)

db.exec(`
    create table if not exists comps(
        id integer primary key autoincrement not null,
        name text not null,
        fzr text not null,
        sjfzr text not null,
        created_at text not null
    );
    `)

const run = () => {
  const inInit = findAll('select * from logs').length
  if (inInit) return
  for (let i = 0; i < 10; i++) {
    const date = Random.date()
    const content = Random.cparagraph()
    db.exec(`
      INSERT INTO logs (date,content,created_at) VALUES ('${date}','${content}',datetime())
      `)
  }
}

run()
